package cn.edu.scau.cmi.wujingxuan.comprehensive;

import cn.edu.scau.cmi.wujingxuan.Adapater.AdapterClient;
import cn.edu.scau.cmi.wujingxuan.Factory.AbstractFactory.AFClient;
import cn.edu.scau.cmi.wujingxuan.Factory.FactoryMethod.FMClient;
import cn.edu.scau.cmi.wujingxuan.Factory.SimpleFactory.SFClient;
import cn.edu.scau.cmi.wujingxuan.composite.consistent.ConsistentClient;
import cn.edu.scau.cmi.wujingxuan.composite.safe.SafeClient;
import cn.edu.scau.cmi.wujingxuan.multipleton.MultipletonClient;
import cn.edu.scau.cmi.wujingxuan.singleton.SingletonClient;
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class Client extends Application
{
	private Stage stage = new Stage();
	private Button bt_Singleton = new Button("实验一：单例模式");
	private Button bt_Multipleton = new Button("实验一：多例模式");
	private Button bt_SF = new Button("实验二：简单工厂模式");
	private Button bt_FM = new Button("实验二：工厂方法模式");
	private Button bt_AF = new Button("实验二：抽象工厂模式");
	private Button bt_Adapter = new Button("实验三：适配器模式");
	private Button bt_CC = new Button("实验四：安全组合模式");
	private Button bt_SC = new Button("实验四：一致性组合模式");

	@Override
	public void start(Stage primaryStage)
	{
		VBox imfBox = new VBox(5);
		Image image = new Image("IMG_4432.JPG");
		ImageView imageView = new ImageView(image);
		imageView.setFitHeight(350);
		imageView.setFitWidth(300);
		imfBox.getChildren().add(imageView);
		imfBox.getChildren().add(new Label("学号：	201627010125"));
		imfBox.getChildren().add(new Label("姓名：	吴敬煊"));

		VBox btBox = new VBox(20);
		// btBox.setAlignment(Pos.CENTER);
		btBox.getChildren().addAll(bt_Singleton, bt_Multipleton, bt_SF, bt_FM, bt_AF, bt_Adapter, bt_CC, bt_SC);
		bt_Singleton.setPrefSize(200, 30);
		bt_Multipleton.setPrefSize(200, 30);
		bt_SF.setPrefSize(200, 30);
		bt_FM.setPrefSize(200, 30);
		bt_AF.setPrefSize(200, 30);
		bt_Adapter.setPrefSize(200, 30);
		bt_CC.setPrefSize(200, 30);
		bt_SC.setPrefSize(200, 30);
		bt_Singleton.setOnAction(e -> {
			SingletonClient client = new SingletonClient();
			client.start(primaryStage);
		});
		bt_Multipleton.setOnAction(e -> {
			MultipletonClient client = new MultipletonClient();
			client.start(primaryStage);
		});
		bt_SF.setOnAction(e -> {
			SFClient client = new SFClient();
			client.start(stage);
		});
		bt_FM.setOnAction(e -> {
			FMClient client = new FMClient();
			client.start(stage);
		});
		bt_AF.setOnAction(e -> {
			AFClient client = new AFClient();
			client.start(stage);
		});
		bt_Adapter.setOnAction(e -> {
			AdapterClient client = new AdapterClient();
			client.start(stage);
		});
		bt_CC.setOnAction(e -> {
			ConsistentClient client = new ConsistentClient();
			client.start(stage);
		});
		bt_SC.setOnAction(e -> {
			SafeClient client = new SafeClient();
			client.start(stage);
		});

		HBox root = new HBox(50);
		root.getChildren().addAll(imfBox, btBox);
		root.setAlignment(Pos.CENTER);

		Scene scene = new Scene(root, 600, 400);
		primaryStage.setTitle("综合性实验");
		primaryStage.setScene(scene);
		primaryStage.show();
	}

	public static void main(String[] args)
	{
		launch(args);
	}
}